/**
 * 复制文件。
 * @param source 源文件
 * @param dest  目标文件
 * @throws IOException 如果源文件不存在或者目标文件不可写入，抛出IO异常。
 */
public static void copy(File source, File dest)throws IOException {
	FileInputStream fileIS = null;
	FileOutputStream fileOS = null;
	try {
		fileIS = new FileInputStream(source);
		fileOS = new FileOutputStream(dest);
	} catch (FileNotFoundException ex) {
		System.out.println("Source File not exist !");
	}
	FileChannel fic = fileIS.getChannel();
	MappedByteBuffer mbuf = fic.map(
			FileChannel.MapMode.READ_ONLY, 0,source.length());
	fic.close();
	fileIS.close();
	if (!dest.exists()) {
		String destPath = dest.getPath();
		String destDir = destPath.substring(0, destPath
				.lastIndexOf(File.separatorChar));
		File dir = new File(destDir);
		if (!dir.exists()) {
			if (dir.mkdirs()) {
				System.out.println("Directory created");
			} else {
				System.out.println("Directory not created");
			}
		}
	}
	FileChannel foc = fileOS.getChannel();
	foc.write(mbuf);
	foc.close();
	fileOS.close();
	mbuf.clear();
}

/**
 * 复制文件
 * @param source 源文件路径
 * @param dest 目标文件路径
 * @throws IOException 如果源文件不存在或者目标文件不可写入，抛出IO异常。
 */
public static void copyFile(String source, String dest)
		throws IOException {
	copy(new File(source), new File(dest));
}